#!/bin/bash
make clean
NDK=/home/kevin/JYY/android/android-ndk-r21e
HOST_TAG=linux-x86_64
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/${HOST_TAG}
SYSROOT=$TOOLCHAIN/sysroot
export PATH=$PATH:$TOOLCHAIN/bin

function build_android
{
echo "Compiling FDK AAC for $CPU"
./configure \
    --prefix=$PREFIX \
    --disable-shared \
    --enable-static \
    --disable-pic \
    --disable-asm \
    --cross-prefix = $CROSS_PREFIX \
    --host=$ARCH \
    --sysroot=$SYSROOT

make clean
make
make install
echo "The Compilation of x264 for $CPU is completed"
}

#armv8-a
API=21
ARCH=aarch64-linux-android
CPU=armv8-a
export CC=$TOOLCHAIN/bin/$ARCH$API-clang
export CXX=$TOOLCHAIN/bin/$ARCH$API-clang++
export NM=$TOOLCHAIN/bin/${ARCH}-nm
export STRIP=$TOOLCHAIN/bin/${ARCH}-strip
export CFLAGS="-Os -fpic -march=$CPU"
export LDFLAGS=
CROSS_PREFIX=$TOOLCHAIN/bin/${ARCH}-
PREFIX=/home/kevin/Kevin/Projects/JYY01/build/x264/$CPU
build_android

#armv7-a
ARCH=armv7a-linux-androideabi
CPU=armv7-a
export CC=$TOOLCHAIN/bin/$ARCH$API-clang
export CXX=$TOOLCHAIN/bin/$ARCH$API-clang++
export NM=$TOOLCHAIN/bin/${ARCH}-nm
export STRIP=$TOOLCHAIN/bin/${ARCH}-strip
export CFLAGS="-mfloat-abi=softfp -mfpu=neon -march=$CPU"
export LDFLAGS=
CROSS_PREFIX=$TOOLCHAIN/bin/${ARCH}-
PREFIX=/home/kevin/Kevin/Projects/JYY01/build/x264/$CPU
build_android